var echartsTheme = 'macarons';
//var echartsTheme = 'shine';
/*var mgeDsz = {
    tableid: "table1",
    layerindex: null,
    bsTable: null,
    idselect: null
};

mgeDsz.initColumn = function () {
    return [[{
        title: '模型ID号', field: 'mxId', width: "100px", align: 'center', valign: 'middle'
    }, {
        title: '模型名称', field: 'mxmc', width: "200px", align: 'center', valign: 'middle', formatter: function (v) {
            return v;
        }
    }, {
        title: '涉及税种', field: 'sjsz', width: "150px", align: 'center', valign: 'middle', formatter: function (v) {
            return v;
        }
    }, {
        title: '疑点个数', field: 'ydgs', width: "150px", align: 'center', valign: 'middle', formatter: function (v, row) {
            return v;
        }
    }]];
}
var mgeHy= {
    tableid: "table2",
    layerindex: null,
    bsTable: null,
    idselect: null
};

mgeHy.initColumn = function () {
    return [[{
        title: '模型ID号', field: 'mxId', width: "100px", align: 'center', valign: 'middle'
    }, {
        title: '模型名称', field: 'mxmc', width: "200px", align: 'center', valign: 'middle', formatter: function (v) {
            return v;
        }
    }, {
        title: '疑点个数', field: 'ydgs', width: "150px", align: 'center', valign: 'middle', formatter: function (v, row) {
            return v;
        }
    }]];
}*/

$(function () {
    barGo1();
    barGo3();
    barGo5();
    getDsz();
    getHy();
});

function barGo1() {
    var myChart = echarts.init(document.getElementById('div_bar1'), echartsTheme);
    var myChart2 = echarts.init(document.getElementById('div_bar2'), echartsTheme);
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'right',
            y: 'center',
            // data:['有环保自动监测数据但未申报或少申报环保税',
            //      '监测机构监测当月无监测数据进行减免',
            //      '取得土地少缴契税风险',
            //      '水利部门与税务部门取水量/发电量不一致涉及水资源税风险',
            //      '其他'
            //      ]
            data: ['单税种风险模型', '行业风险模型', '其他专题模型']
        },
        series: [
            {
                name: '模型数量',
                type: 'pie',
                radius: ['28%', '55%'],
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: true,
                        position: 'inner',
                        formatter: '{c}'
                    }/*,
                     emphasis: {
                     show: true,
                     textStyle: {
                     fontSize: '30',
                     fontWeight: 'bold'
                     }
                     }*/
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data: []
            }
        ]
    };
    myChart.setOption(option);
    myChart2.setOption(option);

    var lay1 = layer.load({shade: [0.1]});
    $.ajax({
        url: ctx + "/mge/adx/syfx/zhfx/queryFxmx?sd1=MXSL",
        data: {},
        dataType: "json",
        type: 'post',
        success: function (d, s) {

            layer.close(lay1);
            if (d.code == '200') {
                var datas = d.data;
                //隐藏loading动画
                myChart.hideLoading();
                myChart.setOption({
                    legend: {
                        data: datas.legendData
                    },
                    series: [{
                        data: datas.echartsData
                    }]
                });

            } else {
                layer.alert(d.message);
            }
        }, error: function (sta) {
            layer.close(lay1);
            layer.alert("请求失败，请重试或检查网络！");
        }
    });

    var lay1 = layer.load({shade: [0.1]});
    $.ajax({
        url: ctx + "/mge/adx/syfx/zhfx/queryFxmx?sd1=YDSL",
        data: {},
        dataType: "json",
        type: 'post',
        success: function (d, s) {

            layer.close(lay1);
            if (d.code == '200') {
                var datas = d.data;
                //隐藏loading动画
                myChart2.hideLoading();
                myChart2.setOption({
                    legend: {
                        data: datas.legendData
                    },
                    series: [{
                        data: datas.echartsData
                    }]
                });

            } else {
                layer.alert(d.message);
            }
        }, error: function (sta) {
            layer.close(lay1);
            layer.alert("请求失败，请重试或检查网络！");
        }
    });
}

function barGo3() {
    $('#div_bar3').html("");
    var myChart = echarts.init(document.getElementById('div_bar3'), echartsTheme);

    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'right',
            y: 'center',
            // data:['有环保自动监测数据但未申报或少申报环保税',
            //      '监测机构监测当月无监测数据进行减免',
            //      '取得土地少缴契税风险',
            //      '水利部门与税务部门取水量/发电量不一致涉及水资源税风险',
            //      '其他'
            //      ]
            //data: ['单税种风险模型', '行业风险模型', '其他专题模型']
            formatter: function (val) {
                var strs = val.split('');
                var str = '';
                for (var i = 0, s; s = strs[i++];) {
                    str += s;
                    if (!(i % 12)) {
                        str += '\n';
                    }
                }
                return str;
            },
            data: []
        },
        series: [
            {
                name: '模型数量',
                type: 'pie',
                radius: ['28%', '55%'],
                avoidLabelOverlap: true,
                label: {
                    normal: {
                        show: true,
                        //position: 'inner',
                         position: 'outside',
                        formatter: '{c}'
                    }/*,
                     emphasis: {
                     show: true,
                     textStyle: {
                     fontSize: '30',
                     fontWeight: 'bold'
                     }
                     }*/
                },
                labelLine: {
                    normal: {
                        show: true
                    }
                },
                formatter: function (val) {
                    var strs = val.split('');
                    var str = '';
                    for (var i = 0, s; s = strs[i++];) {
                        str += s;
                        if (!(i % 12)) {
                            str += '\n';
                        }
                    }
                    return str;
                },
                data: []
                /*data: [
                 {value: 25, name: '单税种风险模型'},
                 {value: 5, name: '行业风险模型'},
                 {value: 1, name: '其他专题模型'}
                 ]*/
            }
        ]
    };
    myChart.setOption(option);

    var lay1 = layer.load({shade: [0.1]});
    $.ajax({
        url: ctx + "/mge/adx/syfx/zhfx/queryDszFxmx",
        data: {},
        dataType: "json",
        type: 'post',
        success: function (d, s) {

            layer.close(lay1);
            if (d.code == '200') {
                var datas = d.data;
                console.log(d.rows);
                //隐藏loading动画
                myChart.hideLoading();
                myChart.setOption({
                    legend: {
                        data: datas.legendData
                    },
                    series: [{
                        data: datas.echartsData
                    }]
                });

            } else {
                layer.alert(d.message);
            }
        }, error: function (sta) {
            layer.close(lay1);
            layer.alert("请求失败，请重试或检查网络！");
        }
    });

}


function barGo5() {
    $('#div_bar5').html("");
    var myChart = echarts.init(document.getElementById('div_bar5'), echartsTheme);

    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'right',
            y: 'center',
            // data:['有环保自动监测数据但未申报或少申报环保税',
            //      '监测机构监测当月无监测数据进行减免',
            //      '取得土地少缴契税风险',
            //      '水利部门与税务部门取水量/发电量不一致涉及水资源税风险',
            //      '其他'
            //      ]
            data: []
        },
        series: [
            {
                name: '疑点分布情况',
                type: 'pie',
                radius: ['28%', '55%'],
                avoidLabelOverlap: true,
                label: {
                    normal: {
                        show: true,
                        position: 'outside',
                        formatter: '{c}'
                    }/*,
                     emphasis: {
                     show: true,
                     textStyle: {
                     fontSize: '30',
                     fontWeight: 'bold'
                     }
                     }*/
                },
                labelLine: {
                    normal: {
                        show: true
                    }
                },
                data: []
            }
        ]
    };
    myChart.setOption(option);
    var lay1 = layer.load({shade: [0.1]});
    $.ajax({
        url: ctx + "/mge/adx/syfx/zhfx/queryHyFxmx",
        data: {},
        dataType: "json",
        type: 'post',
        success: function (d, s) {

            layer.close(lay1);
            if (d.code == '200') {
                var datas = d.data;
                console.log(d.rows);
                //隐藏loading动画
                myChart.hideLoading();
                myChart.setOption({
                    legend: {
                        data: datas.legendData
                    },
                    series: [{
                        data: datas.echartsData
                    }]
                });

            } else {
                layer.alert(d.message);
            }
        }, error: function (sta) {
            layer.close(lay1);
            layer.alert("请求失败，请重试或检查网络！");
        }
    });
}

function getDsz() {
 /*   var bs = new BgdataTable();
    var opt = new BgOption(mgeDsz.tableid, ctx + "/mge/adx/syfx/zhfx/queryDszFxmx?rad=" + new Date().getTime(), mgeDsz.initColumn(), null, $("#div_bar4").height());

    bs.draw(opt);
    mgeDsz.bsTable = bs;

*/
    var lay = layer.load({shade: [0.1]});
    $.ajax({
        url: ctx + "/mge/adx/syfx/zhfx/queryDszFxmx",
        data: {},
        dataType: "json",
        type: 'post',
        success: function (d, s) {
            console.log(d);
            layer.close(lay);
            if (d.code == '200') {
                $("#table1").bootstrapTable({
                    columns: [[{
                        title: '模型ID号', field: 'mxId', width: "100px", align: 'center', valign: 'middle'
                    }, {
                        title: '模型名称', field: 'mxmc', width: "200px", align: 'center', valign: 'middle', formatter: function (v) {
                            return v;
                        }
                    }, {
                        title: '涉及税种', field: 'sjsz', width: "150px", align: 'center', valign: 'middle', formatter: function (v) {
                            return v;
                        }
                    }, {
                        title: '疑点个数', field: 'ydgs', width: "150px", align: 'center', valign: 'middle', formatter: function (v, row) {
                            return v;
                        }
                    }
                    ]],
                    data: d.rows
                });
            } else {
                layer.alert(d.message);
            }
        }, error: function (sta) {
            layer.close(lay);
            layer.alert("请求失败，请重试或检查网络！");
        }
    });
}

function getHy() {

    var lay = layer.load({shade: [0.1]});
    $.ajax({
        url: ctx + "/mge/adx/syfx/zhfx/queryHyFxmx",
        data: {},
        dataType: "json",
        type: 'post',
        success: function (d, s) {
            console.log(d);
            layer.close(lay);
            if (d.code == '200') {
                $("#table2").bootstrapTable({
                    columns: [[
                        {
                            title: '模型ID号', field: 'mxId', width: "100px", align: 'center', valign: 'middle'
                        }, {
                            title: '模型名称', field: 'mxmc', width: "200px", align: 'center', valign: 'middle', formatter: function (v) {
                                return v;
                            }
                        }, {
                            title: '疑点个数', field: 'ydgs', width: "150px", align: 'center', valign: 'middle', formatter: function (v, row) {
                                return v;
                            }
                        }
                    ]],
                    data: d.rows
                });
            } else {
                layer.alert(d.message);
            }
        }, error: function (sta) {
            layer.close(lay);
            layer.alert("请求失败，请重试或检查网络！");
        }
    });
}